const path = require('path')

function resolve (dir) {
  return path.join(__dirname, '.', dir)
}
module.exports = {
  runtimeCompiler: true,
  devServer: {
    port: 8182,
    https: false, // https:{type:Boolean}
    open: true // 配置自动启动浏览器
  },
  productionSourceMap: false,
  chainWebpack: config => {
    config.module.rule('svg')
      .exclude
      .add(resolve('src/components/icons')) // 处理svg目录
      .end()

    config.module
      .rule('svg-sprite-loader')
      .test(/\.svg$/)
      .include
      .add(resolve('src/components/icons')) // 处理svg目录
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
  },
  css: {
    loaderOptions: {
      // 给 sass-loader 传递选项
      sass: {
        prependData: `
        @import "@/assets/styles/variables.scss";
        @import "~normalize.css";
        @import '@/assets/styles/mixin.scss';
        @import "@/assets/styles/index.scss";
        `
      }
    }
  }
}
